/*

The USER Standard Portal Persister
Replace this file with your own persistence Layer if neccessary.
*/





//Namespace USER
window.NSUSER = window.NSUSER || {};


var handleSuccess = function(o)
{  
  NSUSER.stdPersister.makeArray(o.responseText, NSUSER.stdPersister.vSettings) ;
  //alert(o.responseText) ;  
}

var handleFailure = function(o)
{
   alert("Failed") ;
}


var callback =  
 {  
  success:handleSuccess,   
  failure: handleFailure,   
  argument: { foo:"foo", bar:"bar" },   
  cache:false 
 };  









NSUSER.stdPersister = function(strName, pCallback)
{
   this.asyncReq ;
   this.m_pCallback = pCallback 
	this.Name = strName ;
   this.storeURI = './2112PowerWindows/bsp/xmlSettingsProvider.html?' + 
      '&TOPIC=store'  ;
   this.loadURI = './2112PowerWindows/bsp/xmlSettingsProvider.html?' + 
      '&TOPIC=load'  ;
   this.store = function (strPostData, bCallAsync) {
      var request = YAHOO.util.Connect.asyncRequest('GET', this.storeURI, callback); 
   
   };

   this.load = function ( pCallback ) {
     this.m_pCallback = pCallback ;
     this.asyncReq = YAHOO.util.Connect.asyncRequest('GET', this.loadURI, {success:this.m_pCallback}); };
   this.checkComplete = function()
   {
      return YAHOO.util.Connect.isCallInProgress ( this.asyncReq ) ;
   }

};

NSUSER.stdPersister.vSettings = new Array() ; 


NSUSER.stdPersister.makeArray = function (strResponseXML, resultArray) 
{
	   var parser = new DOMParser() ; //SARISSA
		var domDoc ;
		var i ;			
		
		try
		{					 
			domDoc = parser.parseFromString(strResponseXML, "text/xml") ;			      
		}
		catch (e) 
		{
			alert(e) ;
		}
      var cat = domDoc.getElementsByTagName('*');
      for(  i=0; i < cat.length;i++)
		{
        // alert(cat[i].tagName)  ; //cat.item(i).firstChild.data
        resultArray[cat[i].tagName] = cat.item(i).firstChild.data ; 
      }
}
;

NSUSER.stdPersister.selfTest = function(){alert("NSUSER.stdPersister");};

